package com.example.demo.repository;

import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import com.example.demo.custom.BaseRepository;
import com.example.demo.entity.UsedCar1;
import com.example.demo.entity.UsedCar2;
@Repository
public interface UsedCar2Repository extends BaseRepository<UsedCar2, Integer>{

	List<UsedCar2> findByUsedCar(UsedCar1 usedCar1);


	/**
	 * @param car
	 * @return 通过时间排序得到最新一条
	 */
	@Query(value = "SELECT  *  FROM used_car2 t WHERE t.used_car_id=? ORDER BY t.start_days DESC LIMIT 1 ",nativeQuery=true)
	UsedCar2 findByUsedCar2(Integer id);

}
